package logic

import (
	"api/model/mysql"
	"context"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListAminLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewListAminLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAminLogic {
	return &ListAminLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ListAminLogic) ListAmin(in *house.ListAminRequest) (*house.ListAminResponse, error) {

	var user mysql.User
	mysql.DB.Where("user_status=?", in.UserStatus).Find(&user)

	var users []mysql.User

	mysql.DB.Find(&users)

	var lists []*house.ListAmin

	for _, m := range users {
		amin := house.ListAmin{
			Mobile:      m.Mobile,
			Name:        m.Name,
			IdCord:      m.IdCord,
			IdCordFront: m.IdCordFront,
			IdCordBack:  m.IdCordBack,
			UserStatus:  int64(m.UserStatus),
		}
		lists = append(lists, &amin)
	}

	return &house.ListAminResponse{
		List: lists,
	}, nil
}
